DFROBOT SEN0409 Gravity:I2C LIS2DW12三轴加速度传感器 产品资料 使用教程 | 您所在的位置:网站首页 › 树莓派4b 耗电量 › DFROBOT SEN0409 Gravity:I2C LIS2DW12三轴加速度传感器 产品资料 使用教程 |
LIS2DW12三轴加速度计是一款超低功耗的线性加速度计,该传感器拥有两个独立的可编程中断及专用内部引擎,可实现超多功能,例如自由落体检测、纵向/横向检测、朝向检测、可配置的单击/双击识别、运动检测、运动唤醒以实现高级省电等。我们为您提供了以上功能的示例程序,方便您在项目中轻松使用。 该传感器具有±2g /±4g /±8g /±16g的用户可选全刻度,并能够以1.6 Hz至1600 Hz的输出数据速率测量加速度。它内置多种带宽的多种运行模式,您可以按需选择合适的模式。 注意:Gravity版本没有引出两个可编程中断引脚,若需要使用外部中断的高级功能,请购买Breakout版本 特性 可选量程:±2g /±4g /±8g /±16g 16位数据输出 简单易用的Gravity接口,无需焊接 拨扭开关可方便切换I2C地址 技术规格![]() ![]() 注意:拨钮开关可选择I2C地址为0x18或0x19。micro:bit(v1.5版本)的I2C地址与传感器I2C地址0x19冲突,所以请选择0x18。 M0使用教程请按接线图所示将传感器与M0(或其它主板)相连接即可。 关于如何安装库文件,点击链接 样例代码 样例代码1-读取x,y,z轴加速度(getAcceleration.ino) 样例代码2-睡眠唤醒功能(wakeUp.ino) 样例代码3-敲击检测功能(tap.ino) 样例代码4-敲击中断功能(tapInterrupt.ino) (仅Breakout版本可使用) 样例代码5-自由落体检测功能(freeFall.ino) 样例代码6-自由落体中断功能(freeFallInterrupt.ino) (仅Breakout版本可使用) 样例代码7-运动检测功能(activityDetect.ino) 样例代码8-朝向检测功能(orientation.ino)主要API接口函数列表 DFRobot_LIS2DW12(); /** * @brief Initialize the function * @return true(Initialization succeed)/fasle(Initialization failed) */ bool begin(void); /** * @brief Get chip id * @return 8 bit serial number */ uint8_t getID(); /** * @brief Software reset to restore the value of all registers to the default value */ void softReset(); /** * @brief Enable the chip to continuously collect data * @param enable true(continuous update)/false( output registers not updated until MSB and LSB read) */ void continRefresh(bool enable); /** * @brief Set the filter processing mode * @param path path of filtering eLPF = 0x00,/< low-pass filter path selected>/ eHPF = 0x10,// */ void setFilterPath(ePath_t path); /** * @brief Set the bandwidth of the data * @param bw bandwidth eRateDiv_2 ,// eRateDiv_4 ,/* eRateDiv_10 ,// eRateDiv_20 ,// */ void setFilterBandwidth(eBWFilter_t bw); /** * @brief Set power mode, there are two modes for the sensor to measure acceleration * @n 1.Continuous measurement In this mode, the sensor will continuously measure and store data in its register * @n 2.Single data conversion on demand mode In this mode, the sensor will not make a measurement unless it receives an external request * @param mode power modes to choose from eHighPerformance_14bit // eContLowPwr4_14bit // eContLowPwr3_14bit // eContLowPwr2_14bit // */ void setRange(eRange_t range); /** * @brief Enable detect tap events in the Z direction * @param enable ture(Enable tap detection)\false(Disable tap detection) */ void enableTapDetectionOnZ(bool enable); /** * @brief Enable detect tap events in the Y direction * @param enable ture(Enable tap detection)\false(Disable tap detection) */ void enableTapDetectionOnY(bool enable); /** * @brief Enable detect tap events in the X direction * @param enable ture(Enable tap detection)\false(Disable tap detection) */ void enableTapDetectionOnX(bool enable); /** * @brief Set the tap threshold in the X direction * @param th Threshold(mg),Can only be used in the range of 0~2g */ void setTapThresholdOnX(float th); /** * @brief Set the tap threshold in the Y direction * @param th Threshold(mg),Can only be used in the range of 0~2g */ void setTapThresholdOnY(float th); /** * @brief Set the tap threshold in the Z direction * @param th Threshold(mg),Can only be used in the range of 0~2g */ void setTapThresholdOnZ(float th); /** * @brief Duration of maximum time gap for double-tap recognition. When double-tap * @n recognition is enabled, this register expresses the maximum time between two * @n successive detected taps to determine a double-tap event. * @param dur duration, range:0~15 * @n time = dur * (1/rate)(unit:s) | An example of a linear relationship between an argument and time | |------------------------------------------------------------------------------------------------------------------------| | | | | | | | Data rate | 25 Hz | 100 Hz | 400 Hz | = 800 Hz | |------------------------------------------------------------------------------------------------------------------------| | time |dur*(1s/25)= dur*40ms| dur*(1s/100)= dur*10ms | dur*(1s/400)= dur*2.5ms | dur*(1s/800)= dur*1.25ms | |------------------------------------------------------------------------------------------------------------------------| */ void setTapDur(uint8_t dur); /** * @brief Set the tap detection mode, detect single tap or both single tap and double tap * @param mode Tap detection mode eOnlySingle // eBothSingleDouble // */ void setTapMode(eTapMode_t mode); /** * @brief Set Thresholds for 4D/6D, when the threshold of rotation exceeds the specified angle, a direction change event will occur. * @param degree eDegrees80 // eDegrees70 // eDegrees60 // eDegrees50 // */ void set6DThreshold(e6DTh_t degree); /** * @brief Read the acceleration in the x direction * @return Acceleration data from x(mg), the measurement range is ±2g, ±4g, ±8g or ±16g, set by the setRange() funciton. */ int16_t readAccX(); /** * @brief Read the acceleration in the y direction * @return Acceleration data from y(mg), the measurement range is ±2g, ±4g, ±8g or ±16g, set by the setRange() funciton. */ int16_t readAccY(); /** * @brief Read the acceleration in the z direction * @return Acceleration data from z(mg), the measurement range is ±2g, ±4g, ±8g or ±16g, set by the setRange() funciton. */ int16_t readAccZ(); /** * @brief Detect motion * @return true(Motion generated)/false(No motion) */ bool actDetected(); /** * @brief Detect free fall * @return true(Free-fall detected)/false(No free-fall) */ bool freeFallDetected(); /** * @brief Detect whether the direction of the chip changes when the chip is facing up/down/left/right/forward/back (ie 6D) * @return true(a change in position detected)/false(no event detected) */ bool oriChangeDetected(); /** * @brief Only in 6D (facing up/down/left/right/forward/backward) state can the function get the orientation of the sensor relative to the positive z-axis. * @return eXDown // eXUp // eYDown // eYUp // eZDown // eZUp // */ eOrient_t getOrientation(); /** * @brief Tap detection, can detect it is double tap or single tap * @return eSTap // eDTap // eNoTap, //No tap */ eTap_t tapDetect(); /** * @brief Tap direction source detection * @return eDirXUp // eDirXDown // eDirYUp // eDirYDown // eDirZUp // eDirZDown // */ eTapDir_t getTapDirection(); /** * @brief Wake-up motion direction detection * @return eDirX // eDirY // eDirZ // eDirError,// */ eWakeUpDir_t getWakeUpDir(); /** * @brief In Single data conversion on demand mode, request a measurement. */ void demandData(); 样例代码1-读取x,y,z轴加速度(getAcceleration.ino) 选择getAcceleration.ino |
CopyRight 2018-2019 实验室设备网 版权所有 |